package com.it.xuehang.mapper;

import com.it.xuehang.entity.DailyWeatherForecast;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * <p>
 * 每日天气预报信息表 Mapper 接口
 * </p>
 *
 * @author xuehang
 * @since 2024-12-12
 */
public interface DailyWeatherForecastMapper extends BaseMapper<DailyWeatherForecast> {


    /**
     * 检查是否存在相同城市ID和预报日期的数据
     *
     * @param cityId       城市ID
     * @param forecastDate 预报日期
     * @return 如果存在返回1，否则返回0
     */
    @Select("SELECT COUNT(*) FROM daily_weather_forecast WHERE city_id = #{cityId} AND forecast_date = #{forecastDate}")
    int existsByCityIdAndForecastDate(@Param("cityId") BigDecimal cityId,@Param("forecastDate") LocalDate forecastDate);
}
